const http = require('superagent');
const crypto = require('crypto');
const appid = '20181112000233156';
const appkey = 'KWL70mLumh4TYbZ3XM7H';
const url = 'https://fanyi-api.baidu.com/api/trans/vip/translate';
function tranlate(keyword) {
    let salt = Math.random().toString();
    salt *= 10**salt.length;
    let sign = crypto.createHash('md5').update(appid+keyword+salt+appkey).digest('hex');
    http.get(url)
        .query({q:keyword})
        .query({from:'jp'})
        .query({to:'zh'})
        .query({appid})
        .query({salt})
        .query({sign})
        .end((err,res) =>{
            if(err) console.log(err);
            console.log(res.body);
        });
}
tranlate('あけおめ！！！');